From 86100734007a4bf008cfc4b3801ca3015547c643 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Thu, 9 Nov 2023 08:00:03 -0700 Subject: [PATCH] make qstarz format dynamic (#1212) --- qstarz_bl_1000.cc | 26 +++++++------------------- qstarz_bl_1000.h | 10 +++------- vecs.cc | 4 ++-- 3 files changed, 12 insertions(+), 28 deletions(-) diff --git a/qstarz_bl_1000.cc b/qstarz_bl_1000.cc index 2910a4ab1..a0aadce00 100644 --- a/qstarz_bl_1000.cc +++ b/qstarz_bl_1000.cc @@ -135,7 +135,7 @@ QstarzBL1000Format::qstarz_bl_1000_read_record(QDataStream& stream, route_head* stream >> unused2; if (stream.status() != QDataStream::Ok) { - fatal(FatalMsg() << MYNAME << ": File format error on " << read_fname << ". Perhaps this isn't a Qstarz BL-1000 file"); + fatal(FatalMsg() << MYNAME << ": File format error on " << fname << ". Perhaps this isn't a Qstarz BL-1000 file"); } BL1000_POINT_TYPE type; @@ -171,7 +171,7 @@ QstarzBL1000Format::qstarz_bl_1000_read_record(QDataStream& stream, route_head* default: type = BL1000_POINT_TYPE_UNKNOWN; - fatal(FatalMsg() << MYNAME << ": File format error on " << read_fname << ". Unexpected value for RCR (record reason): " << rcr); + fatal(FatalMsg() << MYNAME << ": File format error on " << fname << ". Unexpected value for RCR (record reason): " << rcr); break; } @@ -205,7 +205,7 @@ QstarzBL1000Format::qstarz_bl_1000_read_record(QDataStream& stream, route_head* fix = fix_unknown; if (type != BL1000_POINT_TYPE_UNKNOWN) { - fatal(FatalMsg() << MYNAME << ": File format error on " << read_fname << ". Unexpected value for fix quality: " << fixQuality); + fatal(FatalMsg() << MYNAME << ": File format error on " << fname << ". Unexpected value for fix quality: " << fixQuality); } break; @@ -219,11 +219,11 @@ QstarzBL1000Format::qstarz_bl_1000_read_record(QDataStream& stream, route_head* // qDebug(waypoint) if ((waypoint->latitude < -90) || (waypoint->latitude > 90)) { - fatal(FatalMsg() << MYNAME << ": File format error on " << read_fname << ". Unexpected value for latitude: " << waypoint->latitude); + fatal(FatalMsg() << MYNAME << ": File format error on " << fname << ". Unexpected value for latitude: " << waypoint->latitude); } if ((waypoint->longitude < -180) || (waypoint->longitude > 180)) { - fatal(FatalMsg() << MYNAME << ": File format error on " << read_fname << ". Unexpected value for longitude: " << waypoint->longitude); + fatal(FatalMsg() << MYNAME << ": File format error on " << fname << ". Unexpected value for longitude: " << waypoint->longitude); } waypoint->altitude = altitude; @@ -268,24 +268,12 @@ QstarzBL1000Format::qstarz_bl_1000_read_record(QDataStream& stream, route_head* * entry points called by gpsbabel main process * ***************************************************************************/ -void -QstarzBL1000Format::rd_init(const QString& fname) -{ - read_fname = fname; -} - -void -QstarzBL1000Format::rd_deinit() -{ - read_fname.clear(); -} - void QstarzBL1000Format::read() { - QFile file(read_fname); + QFile file(fname); if (!file.open(QIODevice::ReadOnly)) { - fatal(FatalMsg() << MYNAME << ": Error opening file " << read_fname); + fatal(FatalMsg() << MYNAME << ": Error opening file " << fname); } QDataStream stream(&file); diff --git a/qstarz_bl_1000.h b/qstarz_bl_1000.h index 2870407e9..2a52c4b9d 100644 --- a/qstarz_bl_1000.h +++ b/qstarz_bl_1000.h @@ -55,6 +55,8 @@ struct qstarz_bl_1000_fsdata : FormatSpecificData { class QstarzBL1000Format : public Format { public: + using Format::Format; + ff_type get_type() const override { return ff_type_file; @@ -69,15 +71,9 @@ public: }; } - void rd_init(const QString& fname) override; + void rd_init(const QString& fname) override {} void read() override; - void rd_deinit() override; void qstarz_bl_1000_read(QDataStream& stream); void qstarz_bl_1000_read_record(QDataStream& stream, route_head* track_route); - -private: - QString read_fname; }; - - #endif diff --git a/vecs.cc b/vecs.cc index 75238c8fc..c4c7a7a99 100644 --- a/vecs.cc +++ b/vecs.cc @@ -162,7 +162,6 @@ struct Vecs::Impl { GarminFitFormat format_fit_fmt; GeoJsonFormat geojson_fmt; GlobalsatSportFormat globalsat_sport_fmt; - QstarzBL1000Format qstarz_bl_1000_fmt; #endif // MAXIMAL_ENABLED const QVector vec_list { @@ -488,11 +487,12 @@ struct Vecs::Impl { nullptr, }, { - &qstarz_bl_1000_fmt, + nullptr, "qstarz_bl-1000", "Qstarz BL-1000", nullptr, nullptr, + &fmtfactory }, { nullptr, -- 2.30.2